package com.lijin.study.java.iotest;

import java.io.IOException;

public class CsvDataGet {

	public char[] csvData(int i, int j) throws IOException

	{

		// int i=2;
		// int j=1;

		CsvFileLoad d = new CsvFileLoad();
		char data_copy[] = new char[10000];
		data_copy = d.CsvFile();

		int count = 0;
		int colum_size = 1;

		for (; data_copy[count] != '\n' && count < 10000; count++) {
			if (data_copy[count] == ',')
				colum_size++;
		}

		int count2 = 0;
		int line_size = 1;

		for (; count2 < 10000 && data_copy[count2] != -1; count2++) {
			if (data_copy[count2] == '\n')
				line_size++;
		}

		if (i > colum_size || j > line_size) {
			System.out.print("There is no data in you are searching for");
			return null;
		}
			
		else

		{
			int line = 1;
			int count3 = 0;
			
			for (; line < j; count3++) {
				if (data_copy[count3] == '\n')
					line++;
			}

			int colum = 1;
			for (; colum < i; count3++) {
				if (data_copy[count3] == ',')
					colum++;
			}

			char answer[] = new char[1000];
			int answer_size = 1;

			for (; data_copy[count3 + 1] != ',' && data_copy[count3 + 1] != '\n'; count3++) {
				answer[answer_size] = data_copy[count3 + 1];
				answer_size++;
			}

			// System.out.print(answer);

			return answer;
		}
	}
}
